package dto

import (
	"gitee.com/kristas/booting-go/internal/demo/model"
	"time"
)

func NewAccountDTO(account *model.Account) *AccountDTO {
	return &AccountDTO{
		FirstName: account.FirstName,
		LastName:  account.LastName,
		Username:  account.Username,
		Phone:     account.Phone,
		Email:     account.Email,
		Enabled:   account.Enabled,
		Gender:    account.Gender,
	}
}

func (r *AccountDTO) ToAccountModel() *model.Account {
	now := time.Now()
	return &model.Account{
		ID:          0,
		FirstName:   r.FirstName,
		LastName:    r.LastName,
		Username:    r.Username,
		Phone:       r.Phone,
		Email:       r.Email,
		Enabled:     r.Enabled,
		Gender:      r.Gender,
		CreatedTime: now,
		UpdatedTime: now,
	}
}
